package com.topisv.tms.repository.stock.outstorage;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.topisv.tms.entity.stock.oustorage.OutstorageBoxItem;

/**
 * 出库箱明细_dao
 * @author ch
 *
 */
public abstract interface OutstorageBoxItemDao extends PagingAndSortingRepository<OutstorageBoxItem, Long>, JpaSpecificationExecutor<OutstorageBoxItem>
{

	@Query("select t from OutstorageBoxItem t where t.boxCode=?")
	List<OutstorageBoxItem> loadByBoxCode(String boxCode);

	@Query("select t from OutstorageBoxItem t where t.bill.billCode=?")
	List<OutstorageBoxItem> loadByBillCode(String billCode);

	@Query("select t from OutstorageBoxItem t where (?1 is null or t.bill.warehouseOutCode=?1) and (?6 is null or t.sku=?6) and ( ?2 is null or t.bill.customerCode=?2) and ( ?3 is null or t.bill.billCode = ?3) and t.bill.createTime between ?4 and ?5 and (t.bill.status='5' or t.bill.status='6')")
	List<OutstorageBoxItem> listByBill(String warehouseCode,String customerCode,String billCode,Date start,Date end,String sku);
}